﻿using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Timers;
using System.Data;
using LibHuman;

namespace Human
{
	/// <summary>
	/// Summary description for frmDanhSachNVNghiViec.
	/// </summary>
	public class frmDanhSachNVNghiViec : System.Windows.Forms.Form
	{
		AccessData mDB = new AccessData();
        string m_user="",s_mmyy="";
		private DataSet ds =new DataSet();

		//private Print rpt=new Print();		
		private System.Windows.Forms.GroupBox groupBox1;
		private System.Windows.Forms.Label label1;
		private System.Windows.Forms.Label label2;
		private System.Windows.Forms.RadioButton rdbDSNhanVienNghiViec;
		private System.Windows.Forms.RadioButton rdbDSNhanVienMoi;
		private System.Windows.Forms.ComboBox cbobThang;
		private System.Windows.Forms.ComboBox cbobNam;
		private System.Windows.Forms.Button butThoat;
		private System.Windows.Forms.Button butIn;
		private System.Windows.Forms.Button butXem;
        private Button btnexel;
		/// <summary>
		/// Required designer variable.
		/// </summary>
		private System.ComponentModel.Container components = null;

		public frmDanhSachNVNghiViec()
		{
			//
			// Required for Windows Form Designer support
			//
			InitializeComponent();

			//
			// TODO: Add any constructor code after InitializeComponent call
			//
		}

		/// <summary>
		/// Clean up any resources being used.
		/// </summary>
		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				if(components != null)
				{
					components.Dispose();
				}
			}
			base.Dispose( disposing );
		}

		#region Windows Form Designer generated code
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{
            System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(frmDanhSachNVNghiViec));
            this.rdbDSNhanVienNghiViec = new System.Windows.Forms.RadioButton();
            this.groupBox1 = new System.Windows.Forms.GroupBox();
            this.rdbDSNhanVienMoi = new System.Windows.Forms.RadioButton();
            this.label1 = new System.Windows.Forms.Label();
            this.label2 = new System.Windows.Forms.Label();
            this.cbobThang = new System.Windows.Forms.ComboBox();
            this.cbobNam = new System.Windows.Forms.ComboBox();
            this.butThoat = new System.Windows.Forms.Button();
            this.butIn = new System.Windows.Forms.Button();
            this.butXem = new System.Windows.Forms.Button();
            this.btnexel = new System.Windows.Forms.Button();
            this.groupBox1.SuspendLayout();
            this.SuspendLayout();
            // 
            // rdbDSNhanVienNghiViec
            // 
            this.rdbDSNhanVienNghiViec.Checked = true;
            this.rdbDSNhanVienNghiViec.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(160)))));
            this.rdbDSNhanVienNghiViec.Location = new System.Drawing.Point(16, 7);
            this.rdbDSNhanVienNghiViec.Name = "rdbDSNhanVienNghiViec";
            this.rdbDSNhanVienNghiViec.Size = new System.Drawing.Size(176, 24);
            this.rdbDSNhanVienNghiViec.TabIndex = 0;
            this.rdbDSNhanVienNghiViec.TabStop = true;
            this.rdbDSNhanVienNghiViec.Text = "Danh sách nhân viên nghỉ việc";
            // 
            // groupBox1
            // 
            this.groupBox1.Controls.Add(this.rdbDSNhanVienMoi);
            this.groupBox1.Controls.Add(this.rdbDSNhanVienNghiViec);
            this.groupBox1.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(160)))));
            this.groupBox1.Location = new System.Drawing.Point(51, 47);
            this.groupBox1.Name = "groupBox1";
            this.groupBox1.Size = new System.Drawing.Size(216, 59);
            this.groupBox1.TabIndex = 1;
            this.groupBox1.TabStop = false;
            // 
            // rdbDSNhanVienMoi
            // 
            this.rdbDSNhanVienMoi.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(160)))));
            this.rdbDSNhanVienMoi.Location = new System.Drawing.Point(16, 31);
            this.rdbDSNhanVienMoi.Name = "rdbDSNhanVienMoi";
            this.rdbDSNhanVienMoi.Size = new System.Drawing.Size(160, 24);
            this.rdbDSNhanVienMoi.TabIndex = 3;
            this.rdbDSNhanVienMoi.Text = "Danh sách nhân viên mới";
            // 
            // label1
            // 
            this.label1.AutoSize = true;
            this.label1.Font = new System.Drawing.Font("Arial", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.label1.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(160)))));
            this.label1.Location = new System.Drawing.Point(27, 20);
            this.label1.Name = "label1";
            this.label1.Size = new System.Drawing.Size(51, 16);
            this.label1.TabIndex = 2;
            this.label1.Text = "Tháng :";
            // 
            // label2
            // 
            this.label2.AutoSize = true;
            this.label2.Font = new System.Drawing.Font("Arial", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.label2.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(160)))));
            this.label2.Location = new System.Drawing.Point(163, 20);
            this.label2.Name = "label2";
            this.label2.Size = new System.Drawing.Size(43, 16);
            this.label2.TabIndex = 3;
            this.label2.Text = "Năm :";
            // 
            // cbobThang
            // 
            this.cbobThang.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
            this.cbobThang.Font = new System.Drawing.Font("Arial", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.cbobThang.ForeColor = System.Drawing.Color.Blue;
            this.cbobThang.Items.AddRange(new object[] {
            "01",
            "02",
            "03",
            "04",
            "05",
            "06",
            "07",
            "08",
            "09",
            "10",
            "11",
            "12"});
            this.cbobThang.Location = new System.Drawing.Point(74, 16);
            this.cbobThang.Name = "cbobThang";
            this.cbobThang.Size = new System.Drawing.Size(56, 24);
            this.cbobThang.TabIndex = 4;
            this.cbobThang.SelectedIndexChanged += new System.EventHandler(this.cbobThang_SelectedIndexChanged);
            // 
            // cbobNam
            // 
            this.cbobNam.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
            this.cbobNam.Font = new System.Drawing.Font("Arial", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.cbobNam.ForeColor = System.Drawing.Color.Blue;
            this.cbobNam.Items.AddRange(new object[] {
            "1998",
            "1999",
            "2000",
            "2001",
            "2002",
            "2003",
            "2004",
            "2005",
            "2006",
            "2007",
            "2008",
            "2009",
            "2010"});
            this.cbobNam.Location = new System.Drawing.Point(204, 16);
            this.cbobNam.Name = "cbobNam";
            this.cbobNam.Size = new System.Drawing.Size(80, 24);
            this.cbobNam.TabIndex = 5;
            // 
            // butThoat
            // 
            this.butThoat.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.butThoat.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(160)))));
            this.butThoat.Image = ((System.Drawing.Image)(resources.GetObject("butThoat.Image")));
            this.butThoat.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
            this.butThoat.Location = new System.Drawing.Point(234, 127);
            this.butThoat.Name = "butThoat";
            this.butThoat.Size = new System.Drawing.Size(60, 28);
            this.butThoat.TabIndex = 10;
            this.butThoat.Text = "Thoát";
            this.butThoat.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
            this.butThoat.Click += new System.EventHandler(this.butThoat_Click);
            // 
            // butIn
            // 
            this.butIn.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.butIn.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(160)))));
            this.butIn.Image = ((System.Drawing.Image)(resources.GetObject("butIn.Image")));
            this.butIn.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
            this.butIn.Location = new System.Drawing.Point(87, 127);
            this.butIn.Name = "butIn";
            this.butIn.Size = new System.Drawing.Size(60, 28);
            this.butIn.TabIndex = 9;
            this.butIn.Text = "In";
            this.butIn.Click += new System.EventHandler(this.butIn_Click);
            // 
            // butXem
            // 
            this.butXem.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.butXem.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(160)))));
            this.butXem.Image = ((System.Drawing.Image)(resources.GetObject("butXem.Image")));
            this.butXem.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
            this.butXem.Location = new System.Drawing.Point(16, 127);
            this.butXem.Name = "butXem";
            this.butXem.Size = new System.Drawing.Size(60, 28);
            this.butXem.TabIndex = 8;
            this.butXem.Text = "  Xem";
            this.butXem.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
            this.butXem.Click += new System.EventHandler(this.butXem_Click);
            // 
            // btnexel
            // 
            this.btnexel.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.btnexel.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(160)))));
            this.btnexel.Image = ((System.Drawing.Image)(resources.GetObject("btnexel.Image")));
            this.btnexel.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
            this.btnexel.Location = new System.Drawing.Point(162, 127);
            this.btnexel.Name = "btnexel";
            this.btnexel.Size = new System.Drawing.Size(60, 28);
            this.btnexel.TabIndex = 11;
            this.btnexel.Text = "Excel";
            this.btnexel.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
            this.btnexel.Click += new System.EventHandler(this.btnexel_Click);
            // 
            // frmDanhSachNVNghiViec
            // 
            this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
            this.ClientSize = new System.Drawing.Size(328, 176);
            this.Controls.Add(this.btnexel);
            this.Controls.Add(this.butThoat);
            this.Controls.Add(this.butIn);
            this.Controls.Add(this.butXem);
            this.Controls.Add(this.cbobNam);
            this.Controls.Add(this.cbobThang);
            this.Controls.Add(this.label2);
            this.Controls.Add(this.label1);
            this.Controls.Add(this.groupBox1);
            this.ForeColor = System.Drawing.Color.DarkBlue;
            this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
            this.MaximizeBox = false;
            this.MinimizeBox = false;
            this.Name = "frmDanhSachNVNghiViec";
            this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
            this.Text = "Báo cáo";
            this.Load += new System.EventHandler(this.frmDanhSachNVNghiViec_Load);
            this.groupBox1.ResumeLayout(false);
            this.ResumeLayout(false);
            this.PerformLayout();

		}
		#endregion

		private void butThoat_Click(object sender, System.EventArgs e)
		{
			this.Close();
		}

		private void print(int prn)
		{
            DataSet dstmp = new DataSet();
            ExportToExcel exp = new ExportToExcel();
            string sql = " SELECT 'BVPSHN' as donvi, to_char(hd.ngaynghi,'mm') as thangnghi,to_char(hd.ngaynghi,'yyyy') as namnghi,";
			sql+=" l.ho||' '||l.ten as hoten,case when l.phai='Nam' then namsinh else '' end as NgaysinhNam,";
			sql+=" case when l.phai='Nam' then '' else namsinh end as Ngaysinhnu,";
			sql+=" l.noio||', '||trim(q.tenquan)||', '||trim(t.tentt) as Choohiennay,l.dienthoai as dienthoai,l.quequan as quequan,";
			sql+=" to_char(hd.ngaynghi,'dd/mm/yyyy') as Ngaynghi,hd.luonghd*(hd.hs_lc+hd.hs_cv) as luong,";
			sql+=" m.tenhd as loaihopdong,l.madv,b.tenbp,l.manv,hd.ngaynghi as ngaynghi,";
            sql += " to_char(now(),'dd') as ngay,to_char(now(),'mm') as thang,to_char(now(),'yyyy') as nam";
			sql+=" ,m.tenhd";
            sql += " FROM " + m_user + ".hopdong hd inner join " + m_user + ".llnv l on hd.manv=l.manv ";
            sql += " left join " + m_user + ".bophan b on l.madv=b.madv";
            sql += " left join " + m_user + ".mahd m on hd.loaihd=m.mahd ";
            sql += " left join " + m_user + ".btdtt t on t.matt=l.t_noio";
            sql += " left join " + m_user + ".btdquan q on q.maqu=l.h_noio";
            sql += " inner join "+m_user+".max_lan ml on hd.manv=ml.manv";            
			sql+=" WHERE hd.lan=ml.lan ";			 
			if(cbobThang.SelectedIndex!=-1) sql+=" and to_char(hd.ngaynghi,'mm')='"+cbobThang.SelectedItem+"'";
            if (cbobNam.SelectedIndex != -1) sql += " and to_char(hd.ngaynghi,'yyyy')='" + cbobNam.SelectedItem + "'";
			ds=mDB.get_data(sql);
			ds.WriteXml(@"xml\DanhSachNVNV.xml",XmlWriteMode.WriteSchema);
            s_mmyy = cbobThang.Text.Trim().PadLeft(2, '0') + cbobNam.Text.Trim().Substring(2, 2);
			if (ds.Tables[0].Rows.Count>0)
			{
                switch (prn)
                {
                    case 1: frmReport f = new frmReport(mDB, ds, "DANH SÁCH NHÂN VIÊN NGHỈ VIỆC", "r_DanhSachNVNV_t.rpt", s_mmyy);
                        f.ShowDialog(this);
                        break;
                    case 2: dstmp = exp_exel(ds);
                        exp.exp_excel_dsnvnghi(dstmp, "DANH SÁCH NHÂN VIÊN NGHỈ", cbobThang.Text.ToString(), cbobNam.Text.ToString(),s_mmyy);
                        break;
                }				
				
			}
			else
				MessageBox.Show("Chưa có đầy đủ lý lịch của nhân viên này","Thông Báo");
		}

		private void print1(int prn,bool _new)
		{
            DataSet dstmp = new DataSet();
            ExportToExcel exp = new ExportToExcel();
            string sql = "";
            sql = " select to_char(hd.ngaydenct,'mm') as Thangct,to_char(hd.ngaydenct,'yyyy') as Namct,";
            sql += " l.ho||' '||l.ten as hoten,case when l.phai='Nam' then namsinh else ' ' end as NgaysinhNam,";
            sql += " case when l.phai='Nữ' then namsinh else ' ' end as Ngaysinhnu,";
            sql += " l.diachi as Choohiennay,l.quequan as quequan,l.dienthoai as dienthoai,";
            if (_new)
                sql += " to_Char(hd.ngaydenct,'dd/mm/yyyy') as Ngayct,";
            else
                sql += " to_char(hd.ngaynghi,'dd/mm/yyyy') as Ngayct,";
            sql += " mn.ma1 as mangach,hd.bac as bac,hd.hs_lc as hsluong, hd.luongct as luong,";
			sql+=" hd.loaihd as Loaihopdong,l.madv as madv,l.manv as manv,to_char(now(),'dd') as ngay,";
            sql += " to_char(now(),'mm') as thang,to_char(now(),'yyyy') as nam,m.tenhd as tenhd,hv.tenhv as tenhv,bc.tenbang as tenbang,b.tenbp as tenbp,'BVĐKBL' as donvi,";
            sql += " ct.tenctdt as ctdt,(case when hd.sobhxh <> ' ' then 'X' else ' ' end ) as bhyt,case when hd.bhyt=1 and hd.bhxh=1 then 'X' else ' ' end as bhxh,l.namtn as namtn ";
            sql += " from " + m_user + ".hopdong hd ";
            sql += " inner join " + m_user + ".llnv l on hd.manv=l.manv ";
            sql += " join " + m_user + ".bophan b on l.madv=b.madv ";
            sql += " join " + m_user + ".mahd m on hd.loaihd=m.mahd ";
            sql += " join " + m_user + ".btdtt t on t.matt=l.t_noio ";
            sql += " join " + m_user + ".btdquan q on q.maqu=l.h_noio ";
            sql += " left join " + m_user + ".hocvan hv on l.mahv=hv.mahv ";
            sql += " left join " + m_user + ".bangcap bc on l.td_nnghiep=bc.mabangcap ";
            sql += " left join " + m_user + ".ctdaotao ct on l.nnghiep=ct.mactdt ";
            sql += " join " + m_user + ".mangach mn on mn.ma=hd.mangach ";
            sql += " inner join "+m_user+".max_lan ml on hd.manv=ml.manv";
            if (_new)
            {
                sql += " where to_char(hd.ngaydenct,'mm')='" + cbobThang.SelectedItem + "' ";
                sql += " and to_char(hd.ngaydenct,'yyyy')='" + cbobNam.SelectedItem + "' ";
            }
            else
            {
                sql += " where to_char(hd.ngaynghi,'mm')='" + cbobThang.SelectedItem + "'";
                sql += " and to_char(hd.ngaynghi,'yyyy')='" + cbobNam.SelectedItem + "' ";
            }
            sql += " and hd.lan=ml.lan";
            sql += " order by b.madv";
			ds=mDB.get_data(sql);
			ds.WriteXml("..\\xml\\DanhSachNVMOI.xml",XmlWriteMode.WriteSchema);
            string msg = "";
            if (_new)
                msg = "DANH SÁCH CBVC ĐANG MỚI HỢP ĐỒNG LAO ĐỒNG LÀM VIỆC NGOÀI BIÊN CHẾ THÁNG "+cbobThang.Text+" - "+cbobNam.Text;
            else
                msg = "DANH SÁCH CBVC NGHĨ VIỆC THÁNG " + cbobThang.Text + " - " + cbobNam.Text; ;
			if (ds.Tables[0].Rows.Count>0)
			{
                switch (prn)
                {
                    case 1: frmReport f = new frmReport(mDB, ds, "DANH SÁCH NHÂN VIÊN MỚI ", "DSCBVCmoiHDlaodongNBC.rpt",s_mmyy);
                        f.ShowDialog(this);
                        break;
                    case 2: dstmp = exp_exel_dsnvmoi(ds);
                        exp.exp_excel_dsnvmoi(dstmp, "DANH SÁCH NHÂN VIÊN MỚI ", cbobThang.Text, cbobNam.Text,s_mmyy);
                        break;
                }					
			}
			else
                MessageBox.Show("Không có dữ liệu!", AccessData.Msg,MessageBoxButtons.OK,MessageBoxIcon.Warning);
		}
        private DataSet exp_exel(DataSet dse)
        {
            string[] str = new string[] { "STT", "Họ Và Tên", "Nam", "Nữ", "Chỗ ở hiện nay", "Điện thoại", "Tên bộ phận", "Ngày nghỉ", "Lương ", "Loại hợp đồng" };
            DataSet dse1 = new DataSet();
            dse1.Tables.Add();
            dse1.Tables[0].Columns.Add("stt", typeof(string));
            dse1.Tables[0].Columns.Add("hoten", typeof(string));
            dse1.Tables[0].Columns.Add("NgaysinhNam", typeof(string));
            dse1.Tables[0].Columns.Add("Ngaysinhnu", typeof(string));
            dse1.Tables[0].Columns.Add("Choohiennay", typeof(string));
            dse1.Tables[0].Columns.Add("dienthoai", typeof(string));            
            dse1.Tables[0].Columns.Add("tenbp", typeof(string));
            dse1.Tables[0].Columns.Add("ngaynghi", typeof(string));
            dse1.Tables[0].Columns.Add("luong", typeof(string));
            dse1.Tables[0].Columns.Add("loaihopdong", typeof(string));           
            int stt = 0;
            DataRow nrow;
            foreach (DataRow r in dse.Tables[0].Rows)
            {
                stt++;
                nrow = dse1.Tables[0].NewRow();
                nrow["stt"] = stt;               
                nrow["Hoten"] = r["Hoten"].ToString();
                nrow["NgaysinhNam"] = r["NgaysinhNam"].ToString();
                nrow["Ngaysinhnu"] = r["Ngaysinhnu"].ToString();               
                nrow["Choohiennay"] = r["Choohiennay"].ToString();
                nrow["dienthoai"] = r["dienthoai"].ToString();
                nrow["tenbp"] = r["tenbp"].ToString();
                nrow["ngaynghi"] = r["ngaynghi"].ToString();               
                nrow["luong"] = r["luong"].ToString();
                nrow["loaihopdong"] = r["loaihopdong"].ToString();                        

                dse1.Tables[0].Rows.Add(nrow);
            }
            return dse1;
        }
        private DataSet exp_exel_dsnvmoi(DataSet dse)
        {
            string[] str = new string[] { "STT", "Họ Và Tên", "Nam", "Nữ", "Quê Quán", "Chổ Ở", "Học Vấn", "Bằng Cấp", "Năm TN", "Bộ Phận", "Ngay CT", "Mã Ngạch", "Bậc", "HS Lương", "Lương","Tham Gia BH","Có Sổ" };
            DataSet dse1 = new DataSet();
            dse1.Tables.Add();
            dse1.Tables[0].Columns.Add("stt", typeof(string));
            dse1.Tables[0].Columns.Add("hoten", typeof(string));
            dse1.Tables[0].Columns.Add("ngaysinhNam", typeof(string));
            dse1.Tables[0].Columns.Add("Ngaysinhnu", typeof(string));
            dse1.Tables[0].Columns.Add("quequan", typeof(string));
            dse1.Tables[0].Columns.Add("Choohiennay", typeof(string));
            dse1.Tables[0].Columns.Add("tenhv", typeof(string));
            dse1.Tables[0].Columns.Add("tenbang", typeof(string));            
            dse1.Tables[0].Columns.Add("namtn", typeof(string));
            dse1.Tables[0].Columns.Add("tenbp", typeof(string));
            dse1.Tables[0].Columns.Add("Ngayct", typeof(string));
            dse1.Tables[0].Columns.Add("mangach", typeof(string));
            dse1.Tables[0].Columns.Add("bac", typeof(string));
            dse1.Tables[0].Columns.Add("hsluong", typeof(string));
            dse1.Tables[0].Columns.Add("luong", typeof(string));            
            dse1.Tables[0].Columns.Add("bhxh", typeof(string));
            dse1.Tables[0].Columns.Add("bhyt", typeof(string));
            
            int stt = 0;
            DataRow nrow;
            foreach (DataRow r in dse.Tables[0].Rows)
            {
                stt++;
                nrow = dse1.Tables[0].NewRow();
                nrow["stt"] = stt;
                nrow["Hoten"] = r["Hoten"].ToString();
                nrow["NgaysinhNam"] = r["NgaysinhNam"].ToString();
                nrow["Ngaysinhnu"] = r["Ngaysinhnu"].ToString();
                nrow["quequan"] = r["quequan"].ToString();
                nrow["Choohiennay"] = r["Choohiennay"].ToString();
                nrow["tenhv"] = r["tenhv"].ToString();
                nrow["tenbang"] = r["tenbang"].ToString();                
                nrow["namtn"] = r["namtn"].ToString();
                nrow["tenbp"] = r["tenbp"].ToString();
                nrow["Ngayct"] = r["Ngayct"].ToString();
                nrow["mangach"] = r["mangach"].ToString();
                nrow["bac"] = r["bac"].ToString();
                nrow["hsluong"] = r["hsluong"].ToString();
                nrow["luong"] = r["luong"].ToString();                
                nrow["bhxh"] = r["bhxh"].ToString();
                nrow["bhyt"] = r["bhyt"].ToString();


                dse1.Tables[0].Rows.Add(nrow);
            }
            return dse1;
        }
		private void butXem_Click(object sender, System.EventArgs e)
		{
            if(rdbDSNhanVienNghiViec.Checked==true)
                print(1);
			if(rdbDSNhanVienMoi.Checked==true)
				print1(1,true);
		}

		private void butIn_Click(object sender, System.EventArgs e)
		{
			if(rdbDSNhanVienNghiViec.Checked==true)
				print1(1,false);
			if(rdbDSNhanVienMoi.Checked==true)
				print1(1,true);
		}

		private void frmDanhSachNVNghiViec_Load(object sender, System.EventArgs e)
		{
            m_user = mDB.user;
            string m_thang = "", m_nam = "";
            m_thang = DateTime.Now.Month.ToString().PadLeft(2,'0');
            m_nam = DateTime.Now.Year.ToString();
            //cbobThang.Items[
            int i=0,y=0;
            for (i = 0; i <= cbobThang.Items.Count - 1; i++)
            {
                if (cbobThang.Items[i].ToString() == m_thang) break;
            }
            cbobThang.SelectedIndex = i;
            for (y = 0; y <= cbobNam.Items.Count - 1; y++)
            {
                if (cbobNam.Items[y].ToString() == m_nam) break;
            }
            cbobNam.SelectedIndex=y;
			
		}

        private void btnexel_Click(object sender, EventArgs e)
        {
            if (rdbDSNhanVienNghiViec.Checked == true)
                print(2);
            if (rdbDSNhanVienMoi.Checked == true)
                print1(2, true);
        }

        private void cbobThang_SelectedIndexChanged(object sender, EventArgs e)
        {

        }

	}
}
